<?
@ session_start();
@ini_set('display_errors', 'on');
require_once('class.lib/config.php');
include_once("class.lib/db.class.php");
include_once("class.lib/user.class.php");
include_once("class.lib/diplome.class.php");
include_once("class.lib/cours.class.php");
include_once("class.lib/domaine.class.php");
include_once("class.lib/mention.class.php");
include_once("class.lib/niveau.class.php");
include_once("class.lib/aa_projet.class.php");

include_once("class.lib/email.class.php");

	

$cin=$_SESSION["cin"];
if($cin=="") { header("Location: ../index.php");   }
$unit=new Projet();
$email_db=new email();



$tab_en_cours=$unit->getUnitDecision($cin,'NULL');

$tab_pre_retenu=$unit->getUnitDecision($cin,'mi');

//$tab_incomplet=$unit->getUnitDecision($cin,'in');

$tab_eval=$unit->getUnitDecision($cin,'ev');

$tab_rejet=$unit->getUnitDecision($cin,'rj');



//$tab_complet=$unit->getUnitDecision($cin,'comp');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title> Liste des projets</title>



<script language="JavaScript">
//PLF-http://www.jejavascript.net/
function OuvrirPop(url,nom,haut,Gauche,largeur,hauteur,options) {
ouvpop=window.open(url,nom,"top="+haut+",left="+Gauche+",width="+largeur+",height="+hauteur+","+options);
}
</script>
<script type="text/javascript" src="javascript.js"></script>

<!--
<script src="scriptaculous/lib/prototype.js" type="text/javascript"></script>
<script src="scriptaculous/src/effects.js" type="text/javascript"></script>
<script type="text/javascript" src="fabtabulous.js"></script>
<script type="text/javascript" src="validation.js"></script>
-->
<link href="presse.css" rel="stylesheet" type="text/css" />



	<script type="text/javascript" src="lib/fancybox/jquery-1.4.3.min.js"></script>
	<script type="text/javascript" src="lib/fancybox/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
	
	<link rel="stylesheet" type="text/css" href="lib/fancybox/fancybox/jquery.fancybox-1.3.4.css" media="screen" />

		<script type="text/javascript">
		  jQuery.noConflict();
		  jQuery(document).ready(function($) {
		    // Code that uses jQuery's $ can follow here.
			
			jQuery(".historique").fancybox({
			
				'positionTitle'	: 'over',
				
				'opacity'		: true,
				
				'overlayShow'	: false,

				'transitionIn'	: 'elastic',

				'transitionOut'	: 'none',
				
				'onComplete': function() {
					
			      jQuery("#fancybox-wrap").css({'top':300+'px', 'bottom':'auto'});
				 // alert('');
			   }

			});




		  });
		  
		  function scrollWin(id){
				
				jQuery('html, body').animate({scrollTop: jQuery("#"+id+"").offset().top}, 2000);
				
				}
				
		  function 	toggling(id)
		  {
		  	if (id == "all") {
				jQuery('.cours').show();
				//jQuery('.cours').toggle('fast');
			}
			else 
			{
				jQuery('.cours').hide();
				
				jQuery('#' + id).toggle('fast');
			}
		  }
		  // Code that uses other library's $ can follow here.
		</script>

</head>
<body >

<!--table width="677" height="575" border="0" cellpadding="0" cellspacing="0" align="center" >
    <tr>
    	<td--><H1><font color="DD0269">Liste des projets</font></H1><br/>
   <p><u> 
<!--H1>Information(s) concernant le dipl&ocirc;me et l'unit&eacute; d'enseignement:</p> <br />
</H1-->
</u>
	<strong>Projet : </strong> 
	<select onchange="toggling(jQuery(this).val());" style="font-size:14px;HEIGHT: 30px;">
	<option value="all" selected>Tous les projets</option>
	<option value="encours" >En cours</option>
	<!--<option value="pre">Pr&eacute;-retenus</option>
	<option value="eval">En &eacute;valuation</option>
	<option value="rej">Rejet&eacute;s</option>
	-->
	</select>
<u>
<H1>&nbsp; </H1>
</u> 

<table class="table" width="481" border="0" align="center" cellpadding="0" cellspacing="0" >
 
  <tbody>
  <tr align="left"  id="encours" class="cours"  > 
          <td width="480" height="50">
          	<em><font color="#277BB0"><strong> </strong></font></em> 
            
            
             <table  class="table" width="109%" border="0" cellpadding="0" cellspacing="0" id="tab">
                <tr> 
                  <td height="13" colspan="3" align="left" class="titrebleu2">
                  	<strong><img src="images/navi_arerow.gif" width="6" height="21" align="absmiddle" /> 
                   <font color="#277BB0"  size="4px">Projets propos&eacute;s :</font></strong></td>
                </tr>
                <tr valign="top" bgcolor="#345491"> 
                  <td colspan="5"><img src="images/gif/pix.gif" width="1" height="1"></td>
                </tr>
				
				 
  			<tr>
				<th width="320" height="20" align="left" ><strong>Projet</strong></th>
			   <th width="100"  height="20" align="left"><strong>&eacute;tat de suivi</strong></th>
				<th width="5"  height="20" align="center"><strong>Emails envoy&eacute;s</strong></th>
			
					<th width="123"  height="20" align="right" class="required_info"><strong>Actions</strong></th>
			</tr> 
	
 			<tr valign="top" bgcolor="#345491"> 
                  <td colspan="5"><img src="images/gif/pix.gif" width="1" height="1"></td>
             </tr>
  
				<?php
				if($tab_en_cours)
				{
				 foreach($tab_en_cours as $key => $value){ ?>
                <tr class="ligne"> 
                  <td width="370" height="20" align="left" class="titrebleu2"><span class="Style5"><font color="DD0269">*</font></span> 
                    <?php echo $value['lib_unite']; ?></td>
                  <td  width="50"  height="20" align="left">
				<?php
			echo ($value['revision']=="c" ? "<img src=\"../images/flag-grey.png\" width=\"20\" title=\""."non suivi"."\"  />" :
				($value['revision']=="1" ?"<img src=\"../images/flag-green.png\" width=\"20\"   title=\""."Indicateur de suivi : Sans fautes"."\"/>" :
					"<img src=\"../images/flag-red.png\" width=\"20\"   title=\""."Indicateur de suivi : Avec fautes"."\" />"
					))
			
			?>
				 </td>
				  <td width="5"  height="20" align="center">
				 
				 <?php 
				 
				 $nb=$email_db->calculnbremail($value['code_ue']);
				 echo "<a style=\"float:left;\" class=\"historique\" href=\"../views/historique.call.php?code_ue=".$value['code_ue']."\" 
				title=\"".$value['lib_unite']." : Historique. e-mails\" 
				onclick=\"return false;\">
				$nb<img src=\"../images/mail.png\"  title=\"consulter (".$nb.") e-mails \"/></a>";	
				 
				  ?>
				
				  </td>
                  <td width="123"  height="20" align="right" class="required_info"> 
				  <a href="consult_cours.php?id_ue=<?php echo $value['code_ue']; ?>"><img src="../images/view.png"  title="consulter"/></a>
				  <a href="modif_cours.php?id_ue=<?php echo $value['code_ue']; ?>" title="modif_cours.php?id_ue=<?php echo $value['code_ue']; ?>"><img src="../images/edit.png" title="modifier"/></a>
				  <a  href="<?php echo Urlext.'?id_ue='.$value['code_ue']?>" target="_blank"  title="Imprimer l'appel &agrave; projet"><img src="images/print.png" width="24px" height="24px"/></a>
				
				  </td>
                </tr>
				<?php }
				}
					else  echo '<tr><td> pas de projet en ce moment </td></tr>'; 
				 ?>
			 </table>
           
	  
		 
       </td>
    </tr>
	
	
	
	


  </table>
  </td>
    </tr>
</table>
<!--/td></tr>

</table-->

<p> 
  <?
 if(!empty($_POST['Submit4']))
{
	$diplome=$_POST["diplome"];
	$domaine=$_POST["domaine"];
	$mention=$_POST["mention"];
	$nature= $_POST["nature_ue"];
	$lib= $_POST["unite_enseignement"];
	$semestre=$_POST["semestre"];
	
    if($diplome == "0" || $domaine=="0" || $mention=="0" || $nature=="0" || $lib=="" || $semestre=="0")
	{
	 $etat = "2";
	 }else {
	 $etat = "1";
	}	
	 $ue_tab["code_diplome"]             =   $_POST["diplome"];
    
     $ue_tab["code_niveau"]              =   $_POST["semestre"];
     
	 $ue_tab["code_domaine"]             =   $_POST["domaine"];
     
	 $ue_tab["code_mention"]             =   $_POST["mention"];
     
	 $ue_tab["specialite"]               =   $_POST["specialite_cours"];
	 
     $ue_tab["lib_unite"]                =   $_POST["unite_enseignement"];
     
     $ue_tab["nature_unite"]             =   $_POST["nature_ue"];
	 	 
     $ue_tab["ECUE"]                     =   $_POST["ecue"];
 
     $ue_tab["credit_ects"]              =   $_POST["credit_ects"];
	 
     $ue_tab["volume_cours"]             =   intval($_POST["vh_cours"]);	 
	 $ue_tab["volume_TD"]                =   intval($_POST["vh_td"]);	 
	 $ue_tab["volume_TP"]                =   intval($_POST["vh_tp"]);
	 
	 $ue_tab["coeifficient"]             =   $_POST["coefficient"];
	 
	 $ue_tab["credit"]                   =   $_POST["credit_ects"];
	 
	 $ue_tab["date_soumission"]          =   date("Y-m-d");
     $ue_tab["etat_soumission"]          =   $etat; 
	// R?cup?ration du responsabe du cours
	  
	 
	 
	 
	 $ue_tab["CIN"]                   =   $cin;	 	 
 
	//Ajout de l'enseignant
		$cours = new Cours();
		$res  = $cours->addCours($ue_tab);
		$code_ue=$cours->lastid();
		
		$_SESSION["code"]=$code_ue;
	   
	    $user = new User();
	   //$id_responsable  = $user->getResponsableUe(session_id());     
	   $tab_ens["cin"]= $cin;
	   $tab_ens["code_ue"]=$code_ue;
	   $tab_ens["role"]="Responsable";
	   $ensUe = $user->ensUe($tab_ens);
	
	
	
	
	
	if($res) $_SESSION["etape"]="indexation";
	
	//On actualise la page
	echo "<script language=\"JavaScript\"> document.location=\"indexation.php\"; </script>;";
	} 

  
?>
</p>
</body>
</html>
